![]() ![]() ![]() |
perform()
defined.
They are important for the effective use of the library.
In the places where one would expect to pass a pointer to a function to
a generic algorithm, the interface is specified to accept an object with
an operator()
defined.
For example, if we want to have a by-element addition of two vectors
a
and b
containing Double
and put
the result into a
we can do:
transform(a.begin(), a.end(), b.begin(), a.begin(), new FuncSumDouble());If we want to negate every element of
a
we can do:
transform(a.begin(), a.end(), a.begin(), new FuncNegateDouble());To enable adaptors and other components to manipulate function objects that take zero, one or two arguments interfaces is defined
Function0 api Function1 api Function2 api
FuncSum<type> FuncDifference<type> FuncDivides<type> FuncMultiply<type> FuncNegate<type> FuncModulus<type>for each type
Integer Long Float Double
Function1
where the
single argument is the DataInputStream
to read from,
and the new object just created is returned.
The writing classes implements Function2
where the first
argument is a DataOutputStream
that must be written to
and the second argument is the object that must be written.
The return value is then ignored.
FuncWriter<type> FuncReader<type>for each type
Byte Short Integer Long Float Double Char String BooleanFor text output a FuncTextWriter api function object is created. This object will write the elements to the
DataOutputStream
with their text representaion.
The text representation is created by calling the toString()
method of the object.
![]() ![]() ![]() |